package com.lagou.old;


import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.junit.Test;

import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author: jie.zhao
 * @create: 2021/01/29 23:19
 */
public class OperateDataBase {


    @Test
    public void test() throws ClassNotFoundException, SQLException, PropertyVetoException {
//        Class.forName("com.mysql.jdbc.Driver");

        ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
        comboPooledDataSource.setDriverClass("com.mysql.jdbc.Driver");
        comboPooledDataSource.setUser("root");
        comboPooledDataSource.setPassword("123456");
        comboPooledDataSource.setJdbcUrl("jdbc:mysql://localhost:3307/study");

        Connection connection = comboPooledDataSource.getConnection();

//        Connection connection =
//                DriverManager.getConnection("jdbc:mysql://localhost:3307/study", "root", "123456");

        System.out.println(connection);
    }
}
